import { Instrument } from 'src/instrument/entity/instrument.entity';
import {
  Column,
  CreateDateColumn,
  Entity,
  JoinColumn,
  ManyToOne,
  PrimaryGeneratedColumn,
} from 'typeorm';

@Entity()
export class Booking {
  @PrimaryGeneratedColumn()
  id: number;

  @Column({ comment: '预约者ID' })
  user_id: number;

  @ManyToOne(() => Instrument)
  @JoinColumn({ name: 'instrument_id' })
  instrument: Instrument;

  @Column({ type: 'bigint', comment: '开始时间' })
  start_time: number;

  @Column({ type: 'bigint', comment: '结束时间' })
  end_time: number;

  @Column({
    type: 'int',
    comment: '状态(0:待审核 1:已批准 2:已拒绝 3:已取消 4:已完成 5:未进行)',
  })
  status: number;

  @CreateDateColumn({ comment: '创建时间' })
  created_at: Date;

  @Column({ type: 'boolean', default: false, comment: '是否已签到' })
  isCheckedIn: boolean;

  @Column({ type: 'bigint', nullable: true, comment: '签到时间' })
  checkedInAt: number;
}
